//
//  SRLoadingHUD.m
//  StockpdfReading
//
//  Created by mac on 2017/6/19.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "SRLoadingHUD.h"

@interface SRLoadingHUD ()

@property (nonatomic,strong) MBProgressHUD *hud;

@end


@implementation SRLoadingHUD

-(void)showCustomHud{
    dispatch_async(dispatch_get_main_queue(), ^{
        self.hud.mode = MBProgressHUDModeIndeterminate;
    });
}

-(void)showHudWithProgress:(float)progress{
    dispatch_async(dispatch_get_main_queue(), ^{
        self.hud.mode = MBProgressHUDModeDeterminate;
        self.hud.opacity = 0.8;
        self.hud.dimBackground = YES;
        self.hud.labelText = [NSString stringWithFormat:@"已下载:%.2f%%",progress*100];
        self.hud.progress = progress;
    });
}

-(void)hide{
    dispatch_async(dispatch_get_main_queue(),^{
        [self.hud hide:YES];
        self.hud.removeFromSuperViewOnHide = YES;
    });
}



#pragma mark ---- set get

-(MBProgressHUD *)hud{
    if (_hud == nil) {
        _hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    }
    return _hud;
}





@end











